/**
 *
 *
 * @export
 * @param {((string | number) [])} list
 * @param {number} size 每次按多少个切分
 * @description 数组按指定个数切分，生成新的二维数组
 */
export function arrayChunk(list: (string | number)[], size: number) {
  if (!list || !list.length) return []

  //
  let index = 0 //切割范围的start
  let resIndex = 0 //用来递增表述数组数组的下标
  const listLength = list.length
  const result = new Array(Math.ceil(listLength / size)) //[undefined,undefined,...]
  while (index < listLength) {
    result[resIndex++] = list.slice(index, (index += size)) //slic >= <
  }

  return result
}

/**
 *
 *
 * @export
 * @param {number} milliSecond
 * @description 毫秒转成时分秒
 */

// ----------有问题？？？
export function millisecondToHMSObject(milliSecond: number) {
  if (!milliSecond) {
    return {
      hour: '-',
      minute: '-',
      second: '-'
    }
  }
  const hour = Math.floor(milliSecond / 60 / 60 / 1000)
  const minute = Math.floor(milliSecond / 60 / 1000) % 60 //超过60分钟算一小时
  const second = Math.ceil(milliSecond / 1000) % 60
  return {
    hour,
    minute,
    second
  }
}
